package com.sx.zongzhi.adapter;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sx.zongzhi.R;
import com.sx.zongzhi.bean.WorkLogBean;
import com.sx.zongzhi.utils.BaseUtil;

import java.util.List;


/**
 * Created by XZY on 2017/11/23.
 * 工作日志
 */

public class WorkLogAdapter extends BaseQuickAdapter<WorkLogBean,BaseViewHolder> {

    private Context context;

    public WorkLogAdapter(Context context, @LayoutRes int layoutResId, @Nullable List<WorkLogBean> data) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, WorkLogBean item) {
        helper.setText(R.id.tv_Name, BaseUtil.isEmpty(item.getWorkUserName()) ? "" : item.getWorkUserName());
        helper.setText(R.id.tv_Time, BaseUtil.isEmpty(item.getWorkTime()) ? "" : item.getWorkTime());
        helper.setText(R.id.tv_Title, BaseUtil.isEmpty(item.getTitle()) ? "" : item.getTitle());
        TextView content =  helper.getView(R.id.tv_Content);
        if (BaseUtil.isEmpty(item.getWorkContent())){
            content.setVisibility(View.GONE);
        }else {
            content.setVisibility(View.VISIBLE);
            content.setText(item.getWorkContent());
        }
        ImageView imageView = helper.getView(R.id.imv_Type);
        imageView.setVisibility(View.VISIBLE);//10:文字、30：录音、50：视频、70：相册。
        if (item.getAddWorkDiaryCode() == 10){
            imageView.setVisibility(View.GONE);
        }else if (item.getAddWorkDiaryCode() == 30){
            imageView.setImageResource(R.mipmap.icon_audio);
        }else if (item.getAddWorkDiaryCode() == 50){
            imageView.setImageResource(R.mipmap.icon_video);
        }else if (item.getAddWorkDiaryCode() == 70){
            imageView.setImageResource(R.mipmap.icon_picture);
        }
    }
}
